package com.pwc.conversionTool.rest;

import java.io.IOException;
import java.io.StringReader;
import java.util.List;

import org.jdom.Document;  
import org.jdom.Element;  
import org.jdom.JDOMException;  
import org.jdom.Namespace;  
import org.jdom.input.SAXBuilder;  

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.xml.sax.InputSource;

public class TestXML {
	
	@RequestMapping(value = "/rest/operationMap", method = RequestMethod.GET)
	public @ResponseBody void xmlElements() throws IOException {
		String xml0="<?xml version=\"1.0\" encoding=\"UTF-8\"?><Order><Cid>456</Cid><Pwd>567</Pwd><Pid>678</Pid><Prices><Price>789</Price><Price>商品价格02</Price></Prices></Order>";  
		StringReader read = new StringReader(xml0);
		InputSource source = new InputSource(read);   
        SAXBuilder sb = new SAXBuilder();  
        try {  
            Document doc = sb.build(source);  
            Element root = doc.getRootElement(); 

            List jiedian = root.getChildren();  

            Namespace ns = root.getNamespace();  
            Element et = null;  
            
            for(int i=0;i<jiedian.size() ;i++)
            {  
                et =(Element)  jiedian.get(i);

                System.out.println(et.getValue());  
            }  
        }  
	    catch (JDOMException e)
	  {  
          e.printStackTrace();  
      }  	
	}

}
